import {
  list
} from "@/api/home"
import {
  token_expires
} from '@/utils/Keyword'
const home = {
  state: {
    lists: []
  },
  mutations: {
    HOME_LIST: (state, data) => {
      if (data.page && data.page.data) {
        state.lists = data.page.data;
      }

    }
  },
  actions: {
    HOMELIST({
      commit,
      state
    }, info) {
      return new Promise((resolve, reject) => {
        list(info).then(res => {
          if (res != token_expires) {
            commit("HOME_LIST", res);
            resolve(res)
          } else if(res == token_expires){
            resolve(token_expires)
          }else{
            resolve(token_expires)
          }
        }).catch(err => {
          resolve(false)
        })
      })
    }
  }
}
export default home
